from django.http              import Http404,HttpResponseRedirect
from django.shortcuts         import render_to_response
from django.template          import RequestContext
from sitepal.sitebase.conf    import properties
from sitepal.sitetheme.models import Theme

def theme_front_page(request):
    url = properties.get('site-theme-front-page',admin=True)
    if url:
        return HttpResponseRedirect(url)
    else:
        return render_to_response('theme/welcome.html',context_instance=RequestContext(request))

def theme_media(request,theme,name):
    try:
        theme  = Theme.objects.load_theme(theme)
        medium = theme.get_medium(name)
        return medium.get_response(request)
    except Exception,e:
        print str(e)
    raise Http404,"Unknown medium"
